// createRouter来创建路由实例
// createWebHashHistory代表使用hash模式的路由

import { createRouter, createWebHistory } from 'vue-router'
import home from '../views/home'
import layout from '../views/layout'
import login from '../views/login'
import category from '../views/category'
import goods from '../views/goods'

const routes = [
  {
    path: '/',
    component: layout,
    children: [
      {
        path: '',
        component: home
      },
      {
        path: '/category/:id',
        component: category
      },
      {
        path: '/goods/:id',
        component: goods
      }
    ]
  },
  {
    path: '/login',
    component: login
  }

]

// 生成路由实例对象 导出
const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
